package top.codedance.iotp.converter.service.master;

import top.codedance.iotp.converter.service.Service;
import top.codedance.iotp.converter.service.slave.Slave;

public interface Master extends Service {
    /**
     * 发送数据
     * @param slave
     * @param data
     */
    void send(Slave slave, byte[] data);

    /**
     * 是否是串口
     * @return
     */
    boolean isSerial();

    /**
     * 是否是modbus协议
     * @return
     */
    boolean isModbus();

    boolean tryLock();

    void release();
    /**
     * 发送数据
     * @param data
     * @return
     */
    byte[] request(byte[] data);

    void recover(byte[] data);

    int readHoldingRegister(int offset);

    int[] readHoldingRegisterRange(int offset, int quantity);

    void writeHoldingRegister(int offset, int value);

    void writeHoldingRegisterRange(int offset, int[] range);

    boolean[] readCoilRange(int offset, int quantity);

    void writeCoil(int offset, boolean value);

    void writeCoilRange(int offset, boolean[] range);

    byte[] request(int offset, int quantity);
}
